package com.testmanager.testmananger.shuiyou.common.Constant;

public class DbSql {

    private static final String SEARCHMAINRULE = "select *from sdssbjk_rule_script  t where t.ID=%s";
    private static final String SEARCHPRERULE = " SELECT        sc2.id          ,       sc2.RULE_SCRIPT ,\n" +
            "       m.MODEL_NAME\n" +
            "  from sdssbjk_model_rule  t,       sdssbjk_rule_script sc,      sdssbjk_rule_script sc2,\n" +
            "       sdssbjk_model      m\n" +
            " where t.RULE_ID = sc.id\n" +
            "   and t.PRE_RULE_ID = sc2.ID\n" +
            "   and t.model_id = m.model_id\n" +
            "   and sc.id = %s";
    private static final String SEARCHVARVO = "select * from sdssbjk_rule_var where RULE_ID = %s or RULE_ID in ( SELECT  sc2.id \n" +
            "  from sdssbjk_model_rule  t,       sdssbjk_rule_script sc,      sdssbjk_rule_script sc2,\n" +
            "       sdssbjk_model      m\n" +
            " where t.RULE_ID = sc.id\n" +
            "   and t.PRE_RULE_ID = sc2.ID\n" +
            "   and t.model_id = m.model_id\n" +
            "   and sc.id = %s)";

    private static final String SEARCHRULERESULT = " select *\n" +
            "  from sdssbjk_rule_result r\n" +
            " where   r.rule_id = %s \n" +
            "  and r.analyse_id = (select max(id)\n" +
            "                         from sdssbjk_analyse_result t\n" +
            "                        where t.nsrdzdah = %s ) ";

    public static String  getSearchMainRuleSql(String ruleid){
        return String.format(SEARCHMAINRULE,ruleid);
    }

    public static String getSearchpreruleSql(String ruleid){
        return String.format(SEARCHPRERULE,ruleid);
    }

    public static String getSearchvarvoSql(String ruleid){
        return String.format(SEARCHVARVO,ruleid,ruleid);
    }

    public static String getSearchRuleResult(String ruleid,String nsrid){
        return  String.format(SEARCHRULERESULT,ruleid,nsrid);
    }

}
